﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JacOS.Programs
{
    class login
    {
        public static void run(string tempUser)
        {


            //Get what the user types their password as
            Console.Write("\nType your password >> ");
            var tempPassword = Console.ReadLine();

            //Check if the user name is jacob
            if (tempUser == users.Users.jacob)
            {
                //If the user name entered is jacob, then check if the password is OK
                if (tempPassword == users.jacob.password)
                {
                    //If password is okay than login
                    Console.Write("You have sucessfully logged in as " + users.Users.jacob + ", " + users.jacob.info);
                    MyGlobals.user = users.Users.jacob;
                    MyGlobals.Path = "D:\\Jcoder\\";
                    //Set the current level as the level carried by the new user
                    MyGlobals.current_level = users.jacob.levelv;
                }
                //If the password is not OK then say so
                else
                {
                    Console.Write("Not correct password for " + users.Users.jacob);
                }

            }

            else if (tempUser == users.Users.vinney)
            {
                if (tempPassword == users.vinney.password)
                {
                    Console.Write("You have sucessfully logged in as " + users.Users.vinney + ", " + users.vinney.level);
                    MyGlobals.user = users.Users.vinney;
                    MyGlobals.Path = "D:\\Vcoder\\";
                    MyGlobals.current_level = users.vinney.levelv;
                }
                else
                {
                    Console.Write("Not correct password for " + users.Users.vinney);
                }
            }

            else if (tempUser == users.Users.admin)
            {
                if (tempPassword == users.admin.password)
                {
                    Console.Write("You have sucessfully logged in as " + users.Users.admin + ", " + users.admin.level);
                    MyGlobals.user = "admin";
                    MyGlobals.Path = "D:\\Admin\\";
                    MyGlobals.current_level = users.admin.levelv;
                }
                else
                {
                    Console.Write("Not correct password for " + users.Users.admin);
                }
            }

            else if (tempUser == users.Users.user)
            {
                if (tempPassword == users.user.password)
                {
                    Console.Write("You have sucessfully logged in as " + users.Users.user + ", " + users.user.level);
                    MyGlobals.user = users.Users.user;
                    MyGlobals.Path = "D:\\GenUser\\";
                    MyGlobals.current_level = users.user.levelv;
                }
                else
                {
                    Console.Write("Not correct password for " + users.Users.user);
                }
            }
            else if (tempUser == users.Users.guest)
            {
                if (tempPassword == users.guest.password)
                {
                    Console.Write("You have sucessfully logged in as " + users.Users.guest + ", " + users.guest.level);
                    MyGlobals.user = users.Users.guest;
                    MyGlobals.Path = "D:\\";
                    MyGlobals.current_level = users.guest.levelv;
                }
                else
                {
                    Console.Write("Not correct password for " + users.Users.guest);
                }
            }

            //If the user name is none of those (no account), then say so
            else
            {
                Console.Write(tempUser + " is not a valid account, for a list of valid accounts type accounts");
            }

        }
    }
}
